/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package vn.com.aptech.msh.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author trietto
 */
@Entity
@Table(name = "advertising")
@NamedQueries({
    @NamedQuery(name = "Advertising.findAll", query = "SELECT a FROM Advertising a")})
public class Advertising implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "AdvertisingID")
    private Integer advertisingID;
    @Basic(optional = false)
    @Column(name = "Title")
    private String title;
    @Basic(optional = false)
    @Lob
    @Column(name = "Description")
    private String description;
    @Basic(optional = false)
    @Column(name = "PostDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date postDate;
    @Column(name = "ImagePath")
    private String imagePath;
    @Column(name = "Priority")
    private Integer priority;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "advertising")
    private RentalBasisAccommodation rentalBasisAccommodation;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "advertising")
    private SellingHouse sellingHouse;
    @JoinColumn(name = "Poster", referencedColumnName = "UserID")
    @ManyToOne(optional = false)
    private User user;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "advertising")
    private PayingGuestAccommodation payingGuestAccommodation;

    public Advertising() {
    }

    public Advertising(Integer advertisingID) {
        this.advertisingID = advertisingID;
    }

    public Advertising(Integer advertisingID, String title, String description, Date postDate) {
        this.advertisingID = advertisingID;
        this.title = title;
        this.description = description;
        this.postDate = postDate;
    }

    public Integer getAdvertisingID() {
        return advertisingID;
    }

    public void setAdvertisingID(Integer advertisingID) {
        this.advertisingID = advertisingID;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Date getPostDate() {
        return postDate;
    }

    public void setPostDate(Date postDate) {
        this.postDate = postDate;
    }

    public String getImagePath() {
        return imagePath;
    }

    public void setImagePath(String imagePath) {
        this.imagePath = imagePath;
    }

    public Integer getPriority() {
        return priority;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public RentalBasisAccommodation getRentalBasisAccommodation() {
        return rentalBasisAccommodation;
    }

    public void setRentalBasisAccommodation(RentalBasisAccommodation rentalBasisAccommodation) {
        this.rentalBasisAccommodation = rentalBasisAccommodation;
    }

    public SellingHouse getSellingHouse() {
        return sellingHouse;
    }

    public void setSellingHouse(SellingHouse sellingHouse) {
        this.sellingHouse = sellingHouse;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public PayingGuestAccommodation getPayingGuestAccommodation() {
        return payingGuestAccommodation;
    }

    public void setPayingGuestAccommodation(PayingGuestAccommodation payingGuestAccommodation) {
        this.payingGuestAccommodation = payingGuestAccommodation;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (advertisingID != null ? advertisingID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Advertising)) {
            return false;
        }
        Advertising other = (Advertising) object;
        if ((this.advertisingID == null && other.advertisingID != null) || (this.advertisingID != null && !this.advertisingID.equals(other.advertisingID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "vn.com.aptech.msh.entities.Advertising[advertisingID=" + advertisingID + "]";
    }

}
